<?php
	namespace Qzn\Controller;
	
	require_once('./View/profileView.php');
	
	class ProfileController {
		/**
		 * @return string $html
		 */
		public function DoControll(\Qzn\Model\LoginHandler $lh, \Qzn\Model\Database $db, \Qzn\View\LoginView $lw, \Qzn\Model\ProfileHandler $ph) {
			$html = "";
			$pw = new \Qzn\View\ProfileView();
			
			if ($lh->IsLoggedIn() && $lw->GetUserPk() == \Qzn\View\NavigationView::getProfilePk()) {
				if ($pw->TriedToPressShowResetBox()) {
					$html .= $pw->DoResetPasswordBox();
				}
				if ($pw->TriedToPressResetPassword()) {
					$errorCode = $ph->ChangePassword($pw, $lw);
					$html .= $pw->ErrorHandler($errorCode);
				}
				
				$html .= $pw->DoMyProfileBox($ph, $lw, $lh);
			} else {
				if ($pw->TriedToPressAddFriend()) {
					$ph->SendFriendRequest($lw, $pw);
				}
				
				$html .= $pw->DoProfileBox($ph, $lw, $lh);
			}
			
			return $html;
		}
	}
?>